<!--
 * @Author: 花香蝶自来 1026583651@qq.com
 * @Date: 2024-04-16 18:35:31
 * @LastEditors: xuezhuangzhuang xzz6996@qq.com
 * @LastEditTime: 2025-03-01 23:52:15
 * @FilePath: /crm/components/formz/components/formselect.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <view class="">
    <u-popup :show="showfalg" mode="right" width="500rpx">
      <u-navbar title="用户选择" :autoBack="false" @leftClick="popupback" />
      <view style="width: 750rpx">
        <view class="search-wrap">
          <u-search
            placeholder="请输入名称进行搜索"
            v-model="name"
            bgColor="#FFFFFF"
            height="74rpx"
            placeholderColor="#C1C5C9"
            :showAction="false"
            @change="upper"
          />
        </view>
        <scroll-view
          scroll-y="true"
          class="scroll-Y"
          @scrolltoupper="upper"
          @scrolltolower="lower"
        >
          <!-- 无限滚动列表 -->
          <view v-for="(item, index) in list" :key="index">
            <u-cell :title="item.name" @click="tap(item)"> </u-cell>
          </view>
          <u-loadmore iconType="circle" :status="status" />
        </scroll-view>
      </view>
    </u-popup>
    <customers2 ref="customers2" :item="item" @change="change"></customers2>
  </view>
</template>

<script>
import { getCompanyListPage } from "@/apis/customer/index";
import customers2 from "./customers2.vue";
import listPageMixins from "@/pagescustomer/customer/mixins/scroll-list.js";
export default {
  components: {
    customers2,
  },
  data() {
    return {
      showfalg: false,
      list: [],
      pagination: {},
      queryAPI: getCompanyListPage,
      defaltParams: {},
	  name: ''
    };
  },
  mixins: [listPageMixins],
  props: {
    item: {
      typeof: Object,
      default: () => {
        return {};
      },
    },
  },
  methods: {
    async show(item) {
      this.showfalg = true;
      this.defaltParams = {
        ...(item || {}),
        highSeas: "0",
        size: 20,
      };
	  this.name = ''
      this.upper();
      //   let list = await getCompanyListPage({
      //     customTypeId: item.id,
      //     highSeas: "0",
      //   });
      //   this.list = list.records;
    },
    popupback(e) {
      this.showfalg = false;
    },
    tap(item) {
      if (this.item?.attrs?.customId) {
        this.$emit("change", {
          ...item,
          custom: item.name,
          customId: item.id,
          sysUserId: item.sysUserId,
          sysUserName: item.sysUserName, // 销售人员
        });
        this.showfalg = false;
      } else {
        this.$refs.customers2.show(item);
      }
    },
    change(item) {
      this.$emit("change", item);
      this.showfalg = false;
    },
  },
};
</script>

<style scoped lang="scss">
.search-wrap {
  margin-bottom: 20rpx;
  position: relative;
  z-index: 100;
}
.scroll-Y {
  height: calc(100vh - 400rpx);
}
</style>
